﻿using System;
using System.Collections.Generic;
using OpenTK;

namespace Mono.Rift.Core.Graphics
{
	public class Container : Node
	{
		public List<Node> Nodes { get; set; }
		public bool CollideChildren { get; set; }

		public Container ()
		{
			Nodes = new List<Node> ();
			NodeType = NodeTypes.Container;
			CollideChildren = true;
		}

		public override void clearRenderer ()
		{
			Nodes.ForEach (n => n.clearRenderer ());
		}

		public void add(Node n) {
			Nodes.Add (n);
		}

		public void Add(Model n, Fill f) { 
			n.Fill = f;
			Nodes.Add (n);
		}

		public void removeLast()
		{
			Nodes.RemoveAt (Nodes.Count - 1);
		}

		public void clear()
		{
			Nodes.Clear ();
		}

		public override void render (Matrix4 ltw, RenderDevice device)
		{
			var m = Matrix4.Mult (ltw, Mat);
			foreach (var node in Nodes) {
				node.render (m, device);
			}
		}
	}
}

